using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace FeedFly
{
    /// <summary>
    /// Static class to hold all form objects in memory for quicker UI responsiveness 
    /// </summary>
    public static class Screens
    {
        // Changed all public static fields to properties to allow object creation
        //   Garbage collection was removing some screens

        private static MainForm main;

        public static MainForm Main
        {
            get 
            {
                if (Screens.main == null) Screens.main = new MainForm();
                return Screens.main; 
            }
            set { Screens.main = value; }
        }
        private static ItemListForm itemList;

        public static ItemListForm ItemList
        {
            get 
            {
                if (Screens.itemList == null) Screens.itemList = new ItemListForm();
                return Screens.itemList;
            }
            set { Screens.itemList = value; }
        }
        private static AddFeedForm addFeed;

        public static AddFeedForm AddFeed
        {
            get
            {
                if (Screens.addFeed == null) Screens.addFeed = new AddFeedForm();
                return Screens.addFeed; 
            }
            set { Screens.addFeed = value; }
        }
        private static ItemForm item;

        public static ItemForm Item
        {
            get 
            {
                if (Screens.item == null) Screens.item = new ItemForm();
                return Screens.item; 
            }
            set { Screens.item = value; }
        }
        private static AddFolderForm addFolder;

        public static AddFolderForm AddFolder
        {
            get
            {
                if (Screens.addFolder == null) Screens.addFolder = new AddFolderForm(); 
                return Screens.addFolder;
            }
            set { Screens.addFolder = value; }
        }

        private static EditFeedForm editFeed;

        public static EditFeedForm EditFeed
        {
            get
            {
                if (Screens.editFeed == null) Screens.editFeed = new EditFeedForm();
                return Screens.editFeed;
            }
            set { Screens.editFeed = value; }
        }

        private static FolderSelectForm selectFolder;

        public static FolderSelectForm SelectFolder
        {
            get
            {
                if (Screens.selectFolder == null) Screens.selectFolder = new FolderSelectForm(); 
                return Screens.selectFolder;
            }
            set { Screens.selectFolder = value; }
        }

        public static void Init()
        {
            // main form is not built here since it's the opening screen.
            itemList = new ItemListForm();
            addFeed = new AddFeedForm();
            item = new ItemForm();
            selectFolder = new FolderSelectForm();
            addFolder = new AddFolderForm();
            editFeed = new EditFeedForm();
        }
    }
}
